package com.lagou;

import org.junit.Test;
import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisCluster;
import redis.clients.jedis.JedisPoolConfig;

import java.util.HashSet;
import java.util.Set;

public class Client {

    @Test
    public void test(){

        //Jedis连接池配置
        JedisPoolConfig config = new JedisPoolConfig();
        //Jediscluster节点集合
        Set<HostAndPort> jedisClusterNode = new HashSet<HostAndPort>();
        jedisClusterNode.add(new HostAndPort("192.168.106.129", 7001));
        jedisClusterNode.add(new HostAndPort("192.168.106.129", 7002));
        jedisClusterNode.add(new HostAndPort("192.168.106.129", 7003));
        jedisClusterNode.add(new HostAndPort("192.168.106.129", 7004));
        jedisClusterNode.add(new HostAndPort("192.168.106.129", 7005));
        jedisClusterNode.add(new HostAndPort("192.168.106.129", 7006));
        jedisClusterNode.add(new HostAndPort("192.168.106.129", 7007));
        jedisClusterNode.add(new HostAndPort("192.168.106.129", 7008));

        //节点连接
        JedisCluster jcd = new JedisCluster(jedisClusterNode, config);
        //添加数据
        jcd.set("name","zhaoyun");
        //取出数据
        String value = jcd.get("name");
        System.out.println("name:" + value);
    }
}
